<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<?php echo __CONTENT__;?>/Admin/css/admin.css" rel="stylesheet"
	type="text/css">

<script type="text/javascript" src="<?php echo __CONTENT__;?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo __CONTENT__;?>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo __CONTENT__;?>/js/artDialog.js?skin=black"></script>
<script type="text/javascript" src="<?php echo __CONTENT__;?>/js/WdatePicker.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
	$(".delete").click(function(){
		var url=$(this).attr("href");
		art.dialog({
			id:"delete",
			title:"确认删除",
			content:"您确认要删除此记录吗?",
			lock:true,
			ok:function(){
				location.href=url;
			},
			icon:"question",
			cancel:true
		});
		return false;
	});
	$("#checkAll").click(function(){
		if($(this).attr("checked")){
			$(":checkbox").attr("checked",true);
		}else{
			$(":checkbox").attr("checked",false);
		}
	});
	$("#deleteAll").click(function(){
		if($("input[name='id[]']:checked").size()!=0){
			$("form").submit();
		}else{
			art.dialog({
				id:"delete",
				title:"确认删除",
				content:"请勾选需要删除的数据",
				lock:true,
				ok:true,
				icon:"face-sad"
			});
		}
		return false;
	});
});
function show_error_message(title,msg){
	art.dialog({
		id:"id",
		title:title,
		content:msg,
		lock:true,
		ok:true,
		icon:'face-sad'
	});
}
</script>
<div id="container" class="so_main">
<script type="text/javascript">
$(function(){
	$("form").validate({
		rules : {
			<?php if(!isset($_GET['id'])){?>
			"name" : {
				required : true,
				rangelength : [ 2, 20 ],
				remote:{
					type:"POST",
					url:"<?php echo U('Validate/isRoleNameExist');?>"
				}
			}
			<?php }?>
		},
		messages:{
			name:{
				required:"角色名必须填写",
				rangelength:"角色名必须在2-20个字符之间",
				remote:"角色名已经存在"
			}
		}
	});
	$("#menuAll").click(function(){
		if($(this).attr("checked")){
			$("input[name='menu_id[]']").attr("checked",true);
		}else{
			$("input[name='menu_id[]']").attr("checked",false);
		}
	});
	$("input[name='is_forbid'][value='<?php if(isset($info['is_forbid'])&&$info['is_forbid']!=''){echo $info['is_forbid'];}else{echo '';}?>']").attr("checked",true);
	<?php if(!empty($roleMenuList)){?>
		<?php foreach($roleMenuList as $v){?>
			$("input[name='menu_id[]'][value='<?php echo $v['menu_id'];?>']").attr("checked",true);
		<?php }?>
	<?php }?>
});
</script>
	<div class="page_tit"><?php echo $title;?></div>
	<!-- START CONFIG_FORM -->
	<form method="POST" action="">
	<?php if(isset($_GET['id'])){?>
	<input type="hidden" name="id" value="<?php echo intval($_GET['id']);?>" />
	<?php }?>
		<div class="form2">
			<dl class="lineD">
				<dt>
					<font color="red"></font>角色名：
				</dt>
				<dd>
					<input name="name"  type="text" value="<?php if(isset($info['name'])&&$info['name']!=''){echo $info['name'];}else{echo '';}?>" class="s-txt">
				</dd>
			</dl>
			<dl class="lineD">
				<dt>
					操作：
				</dt>
				<dd>
					<span class="left"><input type="checkbox" name="is_forbid" value="1" class="checkbox"></span>
					<span class="left">禁止</span>
				</dd>
			</dl>
			<dl class="lineD">
				<dt>
					权限：
				</dt>
				<dd>
					<p>
				<input type="checkbox" id="menuAll" class="checkbox"/>
				全选
					</p>
					<div class="clear"></div>
					<?php foreach($menuList as $v){?>
					<p>
					<span class="left"><strong><?php echo $v['name'];?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></span>
						<?php foreach($v['children'] as $item){?>
							<span class="left"><input type="checkbox" <?php if(isset($item['is_open'])){?>checked disabled<?php }else{?>name="menu_id[]" value="<?php echo $item['id'];?>" <?php }?>  />&nbsp;</span>
							<span class="left"><?php echo $item['name'];?></span>
						<?php }?>
					</p>
					<div class="clear"></div>
					<?php }?>
				</dd>
			</dl>
			<dl class="lineD">
				<dt>
					备注：
				</dt>
				<dd>
					<input name="remark"  type="text" value="<?php if(isset($info['remark'])&&$info['remark']!=''){echo $info['remark'];}else{echo '';}?>" class="input-big">
				</dd>
			</dl>
			<div class="page_btm">
				<input type="submit" class="btn_b" value="保存" />
			</div>
		</div>
	</form>
	<!-- END CONFIG_FORM -->
</div>

</html>